package com.hzlx.component.service.impl;

import java.util.List;

import com.hzlx.BomComponentsDto;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.hzlx.component.mapper.BomComponentsMapper;
import com.hzlx.component.domain.BomComponents;
import com.hzlx.component.service.IBomComponentsService;

/**
 * BOM组件明细Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-01
 */
@Service
public class BomComponentsServiceImpl implements IBomComponentsService 
{
    @Autowired
    private BomComponentsMapper bomComponentsMapper;

    @Resource
    private RedisTemplate<String, Object> redisTemplateObject;
    String KEY = "base-data-service:component";
    /**
     * 查询BOM组件明细
     * 
     * @param componentId BOM组件明细主键
     * @return BOM组件明细
     */
    @Override
    public BomComponents selectBomComponentsByComponentId(Long componentId)
    {
        return bomComponentsMapper.selectBomComponentsByComponentId(componentId);
    }

    /**
     * 查询BOM组件明细列表
     * 
     * @param bomComponents BOM组件明细
     * @return BOM组件明细
     */
    @Override
    public List<BomComponents> selectBomComponentsList(BomComponents bomComponents)
    {
        List<BomComponents> list = bomComponentsMapper.selectBomComponentsList(bomComponents);
        redisTemplateObject.opsForValue().set(KEY,list);
        return list;
    }

    @Override
    public List<BomComponents> selectBomComponentsOperationsList(BomComponents bomComponents) {
        return bomComponentsMapper.selectBomComponentsOperationsList(bomComponents);
    }


    /**
     * 新增BOM组件明细
     * 
     * @param bomComponents BOM组件明细
     * @return 结果
     */
    @Override
    public int insertBomComponents(BomComponents bomComponents)
    {
        return bomComponentsMapper.insertBomComponents(bomComponents);
    }

    /**
     * 修改BOM组件明细
     * 
     * @param bomComponents BOM组件明细
     * @return 结果
     */
    @Override
    public int updateBomComponents(BomComponents bomComponents)
    {
        return bomComponentsMapper.updateBomComponents(bomComponents);
    }

    /**
     * 批量删除BOM组件明细
     * 
     * @param componentIds 需要删除的BOM组件明细主键
     * @return 结果
     */
    @Override
    public int deleteBomComponentsByComponentIds(Long[] componentIds)
    {
        return bomComponentsMapper.deleteBomComponentsByComponentIds(componentIds);
    }

    /**
     * 删除BOM组件明细信息
     * 
     * @param componentId BOM组件明细主键
     * @return 结果
     */
    @Override
    public int deleteBomComponentsByComponentId(Long componentId)
    {
        return bomComponentsMapper.deleteBomComponentsByComponentId(componentId);
    }

    @Override
    public List<BomComponents> selectMaterials(Long bomId, Long operationId) {
        return bomComponentsMapper.selectMaterials(bomId, operationId);
    }
}
